<#assign base=request.contextPath>
<!DOCTYPE html> 
<html>
	<head>
		<title></title>
		<meta charset="utf-8">
		<#include "common/reference.ftl" />
		<#include "common/ligerui.ftl" />
		<script type="text/javascript">
		<!--
			var ligerTable = null;
			$(function(){
				$('.select-chosen').chosen();
				ligerTable = $('#table').ligerGrid({
					width:'98%',
					enabledSort:false,
					pageSizeOptions:[5,10,20,50,100,200],
					height:'auto',
					alternatingRow:true,
					url:'${base}/${route}/getList',
					delayLoad:false,
					columns:[
						{display:'服务业务代码',name:'serviceCode',id:'serviceCode',align:'center',minWidth:250},
						{display:'服务业务名称',name:'serviceName',id:'serviceName',align:'center',minWidth:150},
						{
							display:'服务业务图标',
							name:'serviceIcon',
							id:'serviceIcon',
							align:'center',
							minWidth:150,
							render:function(row){
						 		if(row.serviceIcon){
						 			return '<img alt="" src="'+row.serviceIcon+'" heigth="40px">';
						 		}
						 		return '-';
							}
						},
						{
							display:'显示平台',
							name:'platform',
							id:'platform',
							align:'center',
							minWidth:300,
							render:function(row){
								var platform = row.platform;
								if(!platform) return '-';
						 		var pfs = platform.split(',');
						 		var len = pfs != null ? pfs.length : 0;
						 		var html = '';
						 		for(var i = 0; i < len; i++){
						 			var p = pfs[i];
						 			<#if platforms?exists>
						 				<#list platforms as platform>
						 					if( p == '${platform.platformValue}'){
						 						html += '${platform.platformName}  ';
						 					}
						 				</#list>
						 			</#if>
						 		}
						 		return html;
							}
						},
						{
							display:'操作时间',
							name:'operateTime',
							id:'operateTime',
							align:'center',
							minWidth:150,
							render:function(row){
						 		if(row.operateTime > 0){
						 			return formatDate(row.operateTime * 1000);
						 		}
						 		return '-';
							}
						},
						{display:'操作人',name:'operator',id:'operator',align:'center',minWidth:80},
						{
							display:'是否启用',
							name:'enabled',
							id:'enabled',
							align:'center',
							minWidth:150,
							render:function(row){
						 		if(row.enabled){
						 			return '是';
						 		}
						 		return '否';
							}
						}
					],
					onDblClickRow: function (data, rowindex, rowobj){
						layer.open({
							title:'${module}',
							type:2,
							maxmin:false,
							area: ['100%', '100%'],
							content:'${base}/${route}/view/'+data.serviceId
						});
					}
				});
				
				function reload(){
					if(ligerTable){
						var searchKey = $('#txtSearchKey').val();
						ligerTable.setParm('searchKey',searchKey);
						ligerTable.reload();
					}
				}
				$('#btnSearch').click(function(){
					reload();
				})
				$('#btnConfig').click(function(){
					if(ligerTable){
			    		var row = ligerTable.getSelectedRow();
			    		if(!row || row.serviceId < 1){
							layer.msg('请选择行')
			    			return;
			    		}
			    		var serviceId = row.serviceId;
			    		var serviceCode = row.serviceCode;
			    		var url = '';
			    		if(serviceCode == '01'){
			        		url='${base}/${route}/zxpc/'+serviceId;
			    		}
			    		else if(serviceCode == '02'){
			    			url='${base}/${route}/bc/'+serviceId;
			    		}
			    		else if(serviceCode == '03'){
			    			url='${base}/${route}/kc/'+serviceId;
			    		}
			    		else if(serviceCode == '04'){
			    			url='${base}/${route}/sfc/'+serviceId;
			    		}
			    		else if(serviceCode == '05'){
			    			layer.alert('暂无其它配置');
			    			return;
			    		}
			    		else if(serviceCode == '06'){
			    			layer.alert('暂无其它配置');
			    			return;
			    		}
			            changePage(url);
			    	}
				});
				$('#btnEdit').click(function(){
					if(ligerTable){
			    		var row = ligerTable.getSelectedRow();
			    		if(!row || row.serviceId < 1){
							layer.msg('请选择行')
			    			return;
			    		}
			    		var serviceId = row.serviceId;
			        	var url='${base}/${route}/edit/'+serviceId;
			            changePage(url);
			    	}
				});
				$('#btnRemove').click(function(){
					if(ligerTable){
			    		var row = ligerTable.getSelectedRow();
			    		if(!row || row.serviceId < 1){
							layer.msg('请选择行')
			    			return;
			    		}
			    		var serviceId = row.serviceId;
			    		layer.confirm('确定要删除吗？',function(){
			    			$.ajax({
			            		url:'${base}/${route}/remove/'+serviceId,
			            		type:'POST',
			            		data:{},
			            		dataType:'json',
			            		success:function(rst){
			            			layer.alert(rst.message);
			            			if(rst.status=='OK' && ligerTable != null ){
			            				ligerTable.reload();
			            			}
			            		}
			            	});	
			    		});
			    	}
				});
			});
		//-->
		</script>
	</head>
	<body class="$configs["skinName"]">
		<#include "common/breadcrumb.ftl">
		<div class="widget-box">
			<div class="widget-header widget-header-flat">
				<h5 class="lighter">
					<i class="fa fa-search"></i>
					${module}查询
				</h5>
			</div>
			<div class="widget-body">
				<div class="widget-main">
					<div class="row">
						<div class="col-xs-5 col-sm-5">
							<div class="input-group">
								<span class="input-group-addon">关键字</span>
								<input id="txtSearchKey" type="text" class="form-control search-query" placeholder="请输入关键字搜索" />
								<span class="input-group-btn">
									<button id="btnSearch" type="button" class="btn btn-primary btn-sm">
										查询
										<i class="fa fa-search bigger-110"></i>
									</button>
								</span>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
		<div class="widget-box">
			<div class="widget-header">
				<h5 class="lighter">
					<i class="icon-table"></i>
					${module}列表
				</h5>
				<!--非查询者有该操作-->
				<!--
				<#if user?exists && viewerRole?exists && user.roleId != viewerRole>
				<div class="widget-toolbar">
					<button id="btnConfig" type="button" class="btn btn-primary btn-xs">
						<i class="fa fa-cogs"></i>配置其它信息
					</button>

					<button id="btnEdit" type="button" class="btn btn-primary btn-xs">
						<i class="fa fa-check-square-o"></i>编辑
					</button>

					<button id="btnRemove" type="button" class="btn btn-primary btn-xs">
						<i class="fa fa-trash-o"></i>删除
					</button>

				</div>
				</#if>
				-->
			</div>
			<div class="widget-body">
				<div id="table"><div>
			</div>
		</div>
	</body>
</html>